home *** CD-ROM | disk | FTP | other *** search
/ Family Forum 261 / SOMC Family Forum 261.iso / Xtras / Animation Wizard.dir / 00002_Script_Utility routines < prev    next >
Text File  |  1997-05-10  |  4KB  |  131 lines

  1. on Wait nTicks
  2.   set endTime = the ticks + nTicks
  3.   repeat while the ticks < endTime
  4.   end repeat
  5. end Wait
  6.  
  7.  
  8. -- Call this for generic button handling
  9. -- Returns TRUE if the button was pressed
  10. -- or FALSE if the user did not release with the mouse over the button
  11. on PressButton  
  12.   set chButton = the clickOn
  13.   set castNumButtonUp = the castnum of sprite chButton
  14.   
  15.   set btnUpName = the name of cast (castNumButtonUp)
  16.   set nWordsInName = the number of words in btnUpName
  17.   if nWordsInName > 1 then
  18.     if word 2 of btnUpName = "Gray" then
  19.       return FALSE -- button is gray, don't do anything
  20.     end if    
  21.   end if
  22.   
  23.   -- The following assumes the "down button" is one past the "up button" in cast!
  24.   -- For example, there sould be "Book" followed by "Book Down"
  25.   if nWordsInName = 1 then
  26.     set castNumButtonDown = castNumButtonUp + 1  
  27.   else
  28.     set castNumBase = the number of cast(word 1 of btnUpName)
  29.     set castNumButtonDown = castNumBase + 1
  30.   end if
  31.   
  32.   --StartMySound("Click")  
  33.   
  34.   set downFlag = TRUE
  35.   repeat while downFlag
  36.     if rollOver (chButton) then
  37.       set the castnum of sprite chButton = castNumButtonDown
  38.     else
  39.       set the castnum of sprite chButton = castNumButtonUp
  40.     end if
  41.     updateStage
  42.     set downFlag = the stillDown
  43.   end repeat
  44.   --WaitForSound()
  45.   
  46.   set the castnum of sprite chButton = castNumButtonUp
  47.   updateStage
  48.   
  49.   if rollover (chButton) then -- hit the button
  50.     return TRUE
  51.   else  -- did not hit the button
  52.      set the  castnum of sprite chButton = castNumButtonUp
  53.     return FALSE
  54.   end if  
  55. end PressButton
  56.  
  57. -- Call this for generic checkbox button handling
  58. -- Returns TRUE if the user wants to reverse the state of the box
  59. -- or FALSE if not
  60. on PressCheckBox
  61.   set chCheckBox = the clickOn
  62.   set castNumCheckBoxUp = the castnum of sprite chCheckBox
  63.   
  64.   set checkBoxUpName = the name of cast (castNumCheckBoxUp)
  65.   set nWordsInName = the number of words in checkBoxUpName
  66.   if nWordsInName > 1 then
  67.     if word 2 of checkBoxUpName = "Gray" then
  68.       return FALSE -- button is gray, don't do anything
  69.     end if    
  70.   end if
  71.   
  72.   -- The following assumes the "down button" is one past the "up button" in cast!
  73.   set castNumCheckBoxDown = castNumCheckBoxUp + 1  
  74.   
  75.   --StartMySound("Click")    
  76.   set downFlag = TRUE
  77.   repeat while downFlag
  78.     if rollOver (chCheckBox) then
  79.       set the castnum of sprite chCheckBox = castNumCheckBoxDown
  80.     else
  81.       set the castnum of sprite chCheckBox = castNumCheckBoxUp
  82.     end if
  83.     updateStage
  84.     set downFlag = the stillDown
  85.   end repeat
  86.   --WaitForSound()
  87.   
  88.   
  89.   if rollover (chCheckBox) then -- hit the button
  90.     return TRUE
  91.   else  -- did not hit the button
  92.     set the castnum of sprite chCheckBox = castNumCheckBoxUp
  93.     return FALSE
  94.   end if  
  95. end PressCheckBox
  96.  
  97. on IncrMod theCurrentValue, theMaxValue
  98.   if theCurrentValue = theMaxValue then
  99.     return 1
  100.   else
  101.     return (theCurrentValue + 1)
  102.   end if
  103. end IncrMod
  104.  
  105. on DecrMod theCurrentValue, theMaxValue
  106.   if theCurrentValue = 1 then
  107.     return theMaxValue
  108.   else
  109.     return (theCurrentValue - 1)
  110.   end if
  111. end DecrMod
  112.  
  113. on HitWhoH spriteNum, theMax
  114.   set theRealWidth = the right of sprite spriteNum - the left of sprite spriteNum
  115.   set who = (((the mouseH - the left of sprite spriteNum) * theMax) /¼
  116.                  theRealWidth) + 1
  117.   if who <= 1 then
  118.     set who = 1
  119.   end if
  120.   if who > theMax then
  121.     set who = theMax
  122.   end if
  123.   return who
  124. end HitWhoH
  125.  
  126. on Round n
  127.   return integer(n+0.49)
  128. end Round
  129.  
  130.  
  131.